﻿<ribbon:RibbonWindow x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        xmlns:sys="clr-namespace:System;assembly=mscorlib" 
        xmlns:sapt="clr-namespace:System.Activities.Presentation.Toolbox;assembly=System.Activities.Presentation"
        xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
        xmlns:wd="clr-namespace:KumaSystem.WFDesignerExpress"
        Title="MainWindow" x:Name="RibbonWindow"
        Top="{Binding Source={x:Static wd:MySettings.Default}, Path=WindowY}"
        Left="{Binding Source={x:Static wd:MySettings.Default}, Path=WindowX}"
		Width="{Binding Source={x:Static wd:MySettings.Default}, Path=Width}" 
        Height="{Binding Source={x:Static wd:MySettings.Default}, Path=Height}" Style="{Binding}">
    
    <ribbon:RibbonWindow.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
    </ribbon:RibbonWindow.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ribbon:Ribbon x:Name="Ribbon" ShowQuickAccessToolBarOnTop="True" IsCollapsed="False" 
                       IsDropDownOpen="True" IsManipulationEnabled="False" IsMinimized="False" 
                       IsTextSearchEnabled="False" SelectedIndex="0">
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu >
                    <ribbon:RibbonApplicationSplitMenuItem Header="{Binding Source={StaticResource MenuCreateName}}" x:Name="mnuNew"
                                                      ImageSource="{Binding Source={StaticResource IcoNewFlow}}" >
                        <ribbon:RibbonApplicationMenuItem Header="{Binding Source={StaticResource WFSequenceName}}" x:Name="mnuNewSequence" 
                                                          Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFSequence}}"></ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem Header="{Binding Source={StaticResource WFFlowchartName}}" x:Name="mnuNewFlwochart" 
                                                          Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFFlowchart}}"></ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem Header="{Binding Source={StaticResource WFStatemachineName}}" x:Name="mnuNewStatemachine" IsEnabled="False" 
                                                          Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFStatemachine}}"></ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem Header="{Binding Source={StaticResource WFServicesName}}" x:Name="mnuNewWorkflowService" 
                                                          Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFWorkflowservice}}"></ribbon:RibbonApplicationMenuItem>
                    </ribbon:RibbonApplicationSplitMenuItem>
                    <ribbon:RibbonApplicationMenuItem x:Name="mnuOpen"
                                         ImageSource="{Binding Source={StaticResource IcoOpenFlow}}"
                                         Click="OpenWorkflow"
                                         Header="{Binding Source={StaticResource MenuOpenName}}" />
                    <ribbon:RibbonApplicationMenuItem x:Name="mnuSave"
                                         ImageSource="{Binding Source={StaticResource IcoSaveFlow}}"
                                         Click="SaveWorkflow"
                                         Header="{Binding Source={StaticResource MenuSaveName}}" />
                    <ribbon:RibbonSeparator />
                    <ribbon:RibbonApplicationMenuItem x:Name="mnuSqlPersistSetting"
                                         ImageSource="{Binding Source={StaticResource IcoPersistSetting}}"
                                         Click="SettingPersistant"
                                         Header="{Binding Source={StaticResource SetPersistSetting}}" />
                    <ribbon:RibbonSeparator />
                    <ribbon:RibbonApplicationMenuItem x:Name="mnuExit"
                                         Click="QuitApplication"
                                         Header="{Binding Source={StaticResource MenuExitName}}" />

                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>
            
            <ribbon:RibbonTab x:Name="HomeTab" Header="{Binding Source={StaticResource TabHomeName}}">
                <ribbon:RibbonGroup x:Name="Group1"
                                    Header="{Binding Source={StaticResource GroupWorkflowName}}">
                    <ribbon:RibbonMenuButton Label="{Binding Source={StaticResource MenuCreateName}}" x:Name="btnNewWorkflow"
                                                          LargeImageSource="{Binding Source={StaticResource IcoNewFlow}}"
                                                          SmallImageSource="{Binding Source={StaticResource IcoNewFlow}}">
                        <ribbon:RibbonMenuItem Header="{Binding Source={StaticResource WFSequenceName}}" x:Name="mniNewSequence" 
                                               Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFSequence}}"></ribbon:RibbonMenuItem>
                        <ribbon:RibbonMenuItem Header="{Binding Source={StaticResource WFFlowchartName}}" x:Name="mniNewFlowchart" 
                                               Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFFlowchart}}"></ribbon:RibbonMenuItem>
                        <ribbon:RibbonMenuItem Header="{Binding Source={StaticResource WFStatemachineName}}" x:Name="mniNewStateMachine"  IsEnabled="False"
                                               Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFStatemachine}}"></ribbon:RibbonMenuItem>
                        <ribbon:RibbonMenuItem Header="{Binding Source={StaticResource WFServicesName}}" x:Name="mniNewWorkflowService" 
                                               Click="CreateNewWorkflowClick" ImageSource="{Binding Source={StaticResource IcoWFWorkflowservice}}"></ribbon:RibbonMenuItem>
                    </ribbon:RibbonMenuButton> 
                    <ribbon:RibbonButton x:Name="btnOpen"
                                         LargeImageSource="{Binding Source={StaticResource IcoOpenFlow}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoOpenFlow}}"
                                         Click="OpenWorkflow"
                                         Label="{Binding Source={StaticResource MenuOpenName}}" />
                    <ribbon:RibbonButton x:Name="btnSave"
                                         LargeImageSource="{Binding Source={StaticResource IcoSaveFlow}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoSaveFlow}}"
                                         Click="SaveWorkflow"
                                         Label="{Binding Source={StaticResource MenuSaveName}}" />
                   
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Group2"
                                    Header="{Binding Source={StaticResource GroupEditName}}">
                    <ribbon:RibbonButton x:Name="btnUndo" Command="sapv:DesignerView.UndoCommand"
                                         SmallImageSource="{Binding Source={StaticResource IcoUndo}}"
                                         Label="{Binding Source={StaticResource EditUndoName}}" />
                    <ribbon:RibbonButton  x:Name="btnRedo" Command="sapv:DesignerView.RedoCommand"
                                         SmallImageSource="{Binding Source={StaticResource IcoRedo}}"
                                         Label="{Binding Source={StaticResource EditRedoName}}" />
                    <ribbon:RibbonButton Command="sapv:DesignerView.CopyCommand" x:Name="btnCopy"
                                         SmallImageSource="{Binding Source={StaticResource IcoCopy}}"
                                         Label="{Binding Source={StaticResource EditCopyName}}" />
                    <ribbon:RibbonButton Command="sapv:DesignerView.PasteCommand" x:Name="btnPaste"
                                         SmallImageSource="{Binding Source={StaticResource IcoPaste}}"
                                         Label="{Binding Source={StaticResource EditPasteName}}" />
                    <ribbon:RibbonButton Command="sapv:DesignerView.CutCommand" x:Name="btnCut"
                                         SmallImageSource="{Binding Source={StaticResource IcoCut}}"
                                         Label="{Binding Source={StaticResource EditCutName}}" />
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Group4" Header="{Binding Source={StaticResource GroupExecuteName}}">
                    <ribbon:RibbonButton x:Name="btnExecute"
                                         LargeImageSource="{Binding Source={StaticResource IcoPlay}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoPlay}}"
                                         Click="ExecuteWorkflow"
                                         Label="{Binding Source={StaticResource ExecuteRunName}}" />
                    <ribbon:RibbonButton x:Name="btnPause"
                                         LargeImageSource="{Binding Source={StaticResource IcoStop}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoStop}}"
                                         Click="PauseWorkflow"
                                         Label="{Binding Source={StaticResource ExecutePauseName}}" />
                    <ribbon:RibbonButton x:Name="btnViewXaml"
                                         LargeImageSource="{Binding Source={StaticResource IcoViewXaml}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoViewXaml}}"
                                         Click="ViewWorkflowXaml"
                                         Label="{Binding Source={StaticResource ExecuteViewXaml}}" />
                    <ribbon:RibbonCheckBox x:Name="chkExecuteOnConsole" 
                                           Label="{Binding Source={StaticResource ExecuteConsoleName}}" 
                                           IsChecked="{Binding Source={x:Static wd:MySettings.Default}, Path=UseConsole}" />
                    <ribbon:RibbonCheckBox x:Name="chkDisplayTrace"  
                                           Label="{Binding Source={StaticResource ExecuteTraceName}}" 
                                           IsChecked="{Binding Source={x:Static wd:MySettings.Default}, Path=UseTrace}" />
                    <!--<ribbon:RibbonCheckBox x:Name="chkUseIISExp"
                                           IsEnabled="{Binding RelativeSource={RelativeSource Self}}"
                                           Label="{Binding Source={StaticResource ExecuteIISExpress}}"
                                           IsChecked="{Binding Source={x:Static wd:MySettings.Default}, Path=UseIISExp}"/>-->
                    <!--<ribbon:RibbonTextBox x:Name="txtWaitTime" 
                                          Label="{Binding Source={StaticResource ExecuteWaitName}}" 
                                          Text="{Binding Source={x:Static wd:MySettings.Default}, Path=WaitTime}" 
                                          IsEnabled="{Binding ElementName=chkDisplayTrace, Path=IsChecked}"
                                          TextBoxWidth="40" MaxLength="5" TextAlignment="Right" />-->
                    <GroupBox BorderThickness="0" Margin="2">
                        <StackPanel Orientation="Horizontal" 
                                          IsEnabled="{Binding ElementName=chkDisplayTrace, Path=IsChecked}">
                            <Label Content="{Binding Source={StaticResource ExecuteWaitName}}" />
                            <TextBox x:Name="txtWaitTime" 
                                          Text="{Binding Source={x:Static wd:MySettings.Default}, Path=WaitTime}"
                                          Width="40" MaxLength="5" TextAlignment="Right" VerticalContentAlignment="Center" />
                        </StackPanel>
                    </GroupBox>
                </ribbon:RibbonGroup>
                
            </ribbon:RibbonTab>

            <ribbon:RibbonTab x:Name="PersistTab" Header="{Binding Source={StaticResource TabPersistName}}">
                <ribbon:RibbonGroup x:Name="PersistGroup2"
                                    Header="{Binding Source={StaticResource GroupPersistSetting}}">
                    <ribbon:RibbonCheckBox x:Name="chkSqlPersist" Label="{Binding Source={StaticResource ExecutePersistName}}" IsChecked="{Binding Source={x:Static wd:MySettings.Default}, Path=UsePersist}" />
                    <ribbon:RibbonButton x:Name="btnPersistSetting" 
                                         Label="{Binding Source={StaticResource SetPersistSetting}}"
                                         LargeImageSource="{Binding Source={StaticResource IcoPersistSetting}}"
                                         Click="SettingPersistant" IsEnabled="{Binding ElementName=chkSqlPersist, Path=IsChecked}" />
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>

            <ribbon:RibbonTab x:Name="EtcTab" Header="{Binding Source={StaticResource TabEtcName}}">
                <ribbon:RibbonGroup x:Name="Group3" Header="{Binding Source={StaticResource EtcOptionPreInstall}}" MinWidth="180">
                    <ribbon:RibbonCheckBox x:Name="chkWallpaper" Label="{Binding Source={StaticResource ChkUseWallpaper}}" IsChecked="{Binding Source={x:Static wd:MySettings.Default}, Path=UseWallpaper}" />
                    <ribbon:RibbonComboBox IsEnabled="{Binding ElementName=chkWallpaper, Path=IsChecked}" Name="cmbWallpaper" CanAddToQuickAccessToolBarDirectly="False" MinWidth="150">
                        <ribbon:RibbonGallery MaxColumnCount="1" Name="RibbonGallery1">
                            <ribbon:RibbonGalleryCategory Header="{Binding}">
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu00Caption}}" Tag="" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu01Caption}}" Tag="{Binding Source={StaticResource Azu01}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu02Caption}}" Tag="{Binding Source={StaticResource Azu02}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu03Caption}}" Tag="{Binding Source={StaticResource Azu03}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu04Caption}}" Tag="{Binding Source={StaticResource Azu04}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu05Caption}}" Tag="{Binding Source={StaticResource Azu05}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu06Caption}}" Tag="{Binding Source={StaticResource Azu06}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu07Caption}}" Tag="{Binding Source={StaticResource Azu07}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu08Caption}}" Tag="{Binding Source={StaticResource Azu08}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu09Caption}}" Tag="{Binding Source={StaticResource Azu09}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu10Caption}}" Tag="{Binding Source={StaticResource Azu10}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu11Caption}}" Tag="{Binding Source={StaticResource Azu11}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu12Caption}}" Tag="{Binding Source={StaticResource Azu12}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu13Caption}}" Tag="{Binding Source={StaticResource Azu13}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu14Caption}}" Tag="{Binding Source={StaticResource Azu14}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu97Caption}}" Tag="{Binding Source={StaticResource Azu97}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu98Caption}}" Tag="{Binding Source={StaticResource Azu98}, Path=UriSource}" />
                                <ribbon:RibbonGalleryItem Content="{Binding Source={StaticResource Azu99Caption}}" Tag="{Binding Source={StaticResource Azu99}, Path=UriSource}" />
                            </ribbon:RibbonGalleryCategory>
                            <!--<ribbon:RibbonGalleryCategory  DisplayMemberPath="Content">
                            </ribbon:RibbonGalleryCategory>-->
                        </ribbon:RibbonGallery>
                    </ribbon:RibbonComboBox>

                    <!--<ribbon:RibbonCheckBox x:Name="chkVoice" Content="音声" Label="{Binding Source={StaticResource ChkUseVoice}}" IsChecked="{Binding Source={x:Static wd:MySettings.Default}, Path=UseVoice}" />-->
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Group5" Header="{Binding Source={StaticResource GroupLibraryName}}">
                    <ribbon:RibbonButton x:Name="btnAddLibrary"
                                         Click="AddLibrary"
                                         Label="{Binding Source={StaticResource LibraryAddFileName}}"
                                         LargeImageSource="{Binding Source={StaticResource IcoAddLibrary}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoAddLibrary}}"
                                         />
                    <!--<ribbon:RibbonButton x:Name="btnBuildLibrary"
                                         Click="CreateActivityLibrary"
                                         Label="{Binding Source={StaticResource LibraryBuildWorkflow}}"
                                         LargeImageSource="{Binding Source={StaticResource IcoAddLibrary}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoAddLibrary}}"
                                         />-->
                    <!--<ribbon:RibbonButton x:Name="btnReleaseLibrary"
                                         Label="{Binding Source={StaticResource LibraryReleaseFileName}}"
                                         LargeImageSource="{Binding Source={StaticResource IcoReleaseLibrary}}"
                                         SmallImageSource="{Binding Source={StaticResource IcoReleaseLibrary}}"
                                         />-->
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Group99" Header="{Binding Source={StaticResource GroupUISetting}}">
                    <ribbon:RibbonButton x:Name="btnUpSize"
                                          LargeImageSource="{Binding Source={StaticResource IcoZoomIn}}"
                                          SmallImageSource="{Binding Source={StaticResource IcoZoomIn}}"
                                          Click="UIFontSizeChange"
                                             Label="{Binding Source={StaticResource FontSizeUp}}" />
                    <ribbon:RibbonButton x:Name="btnDownSize"
                                          LargeImageSource="{Binding Source={StaticResource IcoZoomOut}}"
                                          SmallImageSource="{Binding Source={StaticResource IcoZoomOut}}"
                                         Click="UIFontSizeChange"
                                             Label="{Binding Source={StaticResource FontSizeDown}}" />
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
            
        </ribbon:Ribbon>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="{Binding Source={x:Static wd:MySettings.Default}, Path=SplitX}"/>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <TabControl Name="ControlGrid" Grid.Column="0" IsTextSearchCaseSensitive="True" IsTextSearchEnabled="True" TabStripPlacement="Bottom" Margin="0">
                <TabItem Header="{Binding Source={StaticResource TabToolbox}}" Padding="4,2">
                    <Border Name="ToolboxArea" >
                        <sapt:ToolboxControl x:Name="toolbox" FontSize="{Binding Source={x:Static wd:MySettings.Default}, Path=ToolBoxFontSize}">
                            <sapt:ToolboxControl.Style>
                                <Style TargetType="{x:Type sapt:ToolboxControl}">
                                    <Style.Resources>
                                        <wd:ToolboxItemConverter x:Key="IconConverter"/>
                                        <DataTemplate x:Key="IconTemplate">
                                            <Rectangle Width="18" Height="18" Fill="{Binding}"/>
                                        </DataTemplate>
                                        <DataTemplate x:Key="ToolTemplate" DataType="{x:Type sapt:ToolboxItemWrapper}">
                                            <Grid >
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto"/>
                                                    <ColumnDefinition Width="*" SharedSizeGroup="toolLabel"/>
                                                </Grid.ColumnDefinitions>
                                                
                                                <ContentControl Grid.Column="0"
                                                        Content="{Binding Path=ToolName, Converter={StaticResource IconConverter}}"
                                                        ContentTemplate="{StaticResource IconTemplate}"/>
                               
                                                <TextBlock Grid.Column="1" Text="{Binding Path=DisplayName}" Margin="5,1,5,0"/>
                                            </Grid>
                                        </DataTemplate>
                                    </Style.Resources>
                                    <Setter Property="ToolTemplate" Value="{StaticResource ToolTemplate}" />
                                </Style>
                            </sapt:ToolboxControl.Style>
                        </sapt:ToolboxControl>
                    </Border>
                </TabItem>

                <TabItem Header="{Binding Source={StaticResource TabProperty}}"  Padding="4,2">
                    <Border Name="PropertyArea" />
                </TabItem>

                <TabItem Header="{Binding Source={StaticResource TabTrace}}"  Padding="4,2" >
                    <Border Name="TraceArea" >
                        <TextBox Name="txtTrace" />
                    </Border>
                </TabItem>

            </TabControl>

            <GridSplitter ResizeDirection="Columns" Grid.Column="1" Width="4" Height="Auto" ResizeBehavior="PreviousAndCurrent" />

            <Border Name="DesignerArea" Grid.Column="2" AllowDrop="True" />
        </Grid>
    </Grid>
</ribbon:RibbonWindow>
